﻿/******************************************************************************
 *  All Rights Reserved , Copyright (C) 2012 , EricHu. 
 *  作    者： EricHu
 *  创建时间： 2012-7-20 16:35:54
 ******************************************************************************/
//--------------------------------------------------------------------
// All Rights Reserved , Copyright (C) 2012 , gt TECH, Ltd.
//--------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;

namespace RDIFramework.BusinessEntity
{
    using RDIFramework.Utilities;

    /// <summary>
    /// PiUserEntity
    /// 用户账户表
    ///
    /// 修改纪录
    ///
    ///		2012-03-02 版本：1.0 EricHu 创建主键。
    ///
    /// 版本：1.0
    ///
    /// <author>
    ///		<name>EricHu</name>
    ///		<date>2012-03-02</date>
    /// </author>
    /// </summary>

    public class PiUserEntity
    {
        #region 私有成员

        private bool _IsChanged;
        private bool _IsDeleted;
        private int? _Id;
        private string _Code;
        private string _UserName;
        private string _RealName;
        private int? _RoleId;
        private string _UserFrom;
        private string _WorkCategory;
        private int? _CompanyId;
        private string _CompanyName;
        private int? _DepartmentId;
        private string _DepartmentName;
        private int? _WorkgroupId;
        private string _WorkgroupName;
        private string _Gender;
        private string _Mobile;
        private string _Telephone;
        private DateTime? _Birthday;
        private string _Duty;
        private string _Title;
        private string _UserPassword;
        private DateTime? _ChangePasswordDate;
        private string _QICQ;
        private string _Email;
        private string _Lang;
        private string _Theme;
        private DateTime? _AllowStartTime;
        private DateTime? _AllowEndTime;
        private DateTime? _LockStartDate;
        private DateTime? _LockEndDate;
        private DateTime? _FirstVisit;
        private DateTime? _PreviousVisit;
        private DateTime? _LastVisit;
        private int _LogOnCount;
        private int _IsStaff;
        private string _AuditStatus;
        private int _IsVisible;
        private int _UserOnLine;
        private string _IPAddress;
        private string _MACAddress;
        private string _HomeAddress;
        private string _OpenId = BusinessLogic.NewGuid();
        private string _Question;
        private string _AnswerQuestion;
        private string _UserAddress;
        private int _DeleteMark;
        private int _Enabled;
        private int? _SortCode;
        private string _Description;
        private DateTime? _CreateOn;
        private string _CreateUserId;
        private string _CreateBy;
        private DateTime? _ModifiedOn;
        private string _ModifyUserId;
        private string _ModifiedBy;

        #endregion

        #region 默认( 空 ) 构造函数
        /// <summary>
        /// 默认构造函数
        /// </summary>
        public PiUserEntity()
        {
            _Id = 0;
            _Code = null;
            _UserName = null;
            _RealName = null;
            _RoleId = null;
            _UserFrom = null;
            _WorkCategory = null;
            _CompanyId = null;
            _CompanyName = null;
            _DepartmentId = null;
            _DepartmentName = null;
            _WorkgroupId = null;
            _WorkgroupName = null;
            _Gender = null;
            _Mobile = null;
            _Telephone = null;
            _Birthday = null;
            _Duty = null;
            _Title = null;
            _UserPassword = null;
            _ChangePasswordDate = null;
            _QICQ = null;
            _Email = null;
            _Lang = null;
            _Theme = null;
            _AllowStartTime = null;
            _AllowEndTime = null;
            _LockStartDate = null;
            _LockEndDate = null;
            _FirstVisit = null;
            _PreviousVisit = null;
            _LastVisit = null;
            _LogOnCount = 0;
            _IsStaff = 0;
            _AuditStatus = null;
            _IsVisible = 0;
            _UserOnLine = 0;
            _IPAddress = null;
            _MACAddress = null;
            _HomeAddress = null;
            _OpenId = null;
            _Question = null;
            _AnswerQuestion = null;
            _UserAddress = null;
            _DeleteMark = 0;
            _Enabled = 0;
            _SortCode = null;
            _Description = null;
            _CreateOn = null;
            _CreateUserId = null;
            _CreateBy = null;
            _ModifiedOn = null;
            _ModifyUserId = null;
            _ModifiedBy = null;
        }
        #endregion

        #region 公有属性

        /// <summary>
        /// 主键
        /// </summary>		
        public virtual int? Id
        {
            get { return _Id; }
            set { _IsChanged |= (_Id != value); _Id = value; }
        }

        /// <summary>
        /// 编号
        /// </summary>		
        public virtual string Code
        {
            get { return _Code; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Code", value, value.ToString());

                _IsChanged |= (_Code != value); _Code = value;
            }
        }

        /// <summary>
        /// 登录名
        /// </summary>		
        public virtual string UserName
        {
            get { return _UserName; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for UserName", value, value.ToString());

                _IsChanged |= (_UserName != value); _UserName = value;
            }
        }

        /// <summary>
        /// 姓名
        /// </summary>		
        public virtual string RealName
        {
            get { return _RealName; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for RealName", value, value.ToString());

                _IsChanged |= (_RealName != value); _RealName = value;
            }
        }

        /// <summary>
        /// 默认角色主键
        /// </summary>		
        public virtual int? RoleId
        {
            get { return _RoleId; }
            set { _IsChanged |= (_RoleId != value); _RoleId = value; }
        }

        /// <summary>
        /// 用户来源
        /// </summary>		
        public virtual string UserFrom
        {
            get { return _UserFrom; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for UserFrom", value, value.ToString());

                _IsChanged |= (_UserFrom != value); _UserFrom = value;
            }
        }

        /// <summary>
        /// 工作行业
        /// </summary>		
        public virtual string WorkCategory
        {
            get { return _WorkCategory; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for WorkCategory", value, value.ToString());

                _IsChanged |= (_WorkCategory != value); _WorkCategory = value;
            }
        }

        /// <summary>
        /// 公司代码
        /// </summary>		
        public virtual int? CompanyId
        {
            get { return _CompanyId; }
            set { _IsChanged |= (_CompanyId != value); _CompanyId = value; }
        }

        /// <summary>
        /// 公司名称
        /// </summary>		
        public virtual string CompanyName
        {
            get { return _CompanyName; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for CompanyName", value, value.ToString());

                _IsChanged |= (_CompanyName != value); _CompanyName = value;
            }
        }

        /// <summary>
        /// 部门代码
        /// </summary>		
        public virtual int? DepartmentId
        {
            get { return _DepartmentId; }
            set { _IsChanged |= (_DepartmentId != value); _DepartmentId = value; }
        }

        /// <summary>
        /// 部门名称
        /// </summary>		
        public virtual string DepartmentName
        {
            get { return _DepartmentName; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for DepartmentName", value, value.ToString());

                _IsChanged |= (_DepartmentName != value); _DepartmentName = value;
            }
        }

        /// <summary>
        /// 工作组代码
        /// </summary>		
        public virtual int? WorkgroupId
        {
            get { return _WorkgroupId; }
            set { _IsChanged |= (_WorkgroupId != value); _WorkgroupId = value; }
        }

        /// <summary>
        /// 工作组名称
        /// </summary>		
        public virtual string WorkgroupName
        {
            get { return _WorkgroupName; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for WorkgroupName", value, value.ToString());

                _IsChanged |= (_WorkgroupName != value); _WorkgroupName = value;
            }
        }

        /// <summary>
        /// 性别
        /// </summary>		
        public virtual string Gender
        {
            get { return _Gender; }
            set
            {
                if (value != null)
                    if (value.Length > 6)
                        throw new ArgumentOutOfRangeException("Invalid value for Gender", value, value.ToString());

                _IsChanged |= (_Gender != value); _Gender = value;
            }
        }

        /// <summary>
        /// 手机
        /// </summary>		
        public virtual string Mobile
        {
            get { return _Mobile; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Mobile", value, value.ToString());

                _IsChanged |= (_Mobile != value); _Mobile = value;
            }
        }

        /// <summary>
        /// 固定电话
        /// </summary>		
        public virtual string Telephone
        {
            get { return _Telephone; }
            set
            {
                if (value != null)
                    if (value.Length > 30)
                        throw new ArgumentOutOfRangeException("Invalid value for Telephone", value, value.ToString());

                _IsChanged |= (_Telephone != value); _Telephone = value;
            }
        }

        /// <summary>
        /// 出生日期
        /// </summary>		
        public virtual DateTime? Birthday
        {
            get { return _Birthday; }
            set { _IsChanged |= (_Birthday != value); _Birthday = value; }
        }

        /// <summary>
        /// 岗位
        /// </summary>		
        public virtual string Duty
        {
            get { return _Duty; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Duty", value, value.ToString());

                _IsChanged |= (_Duty != value); _Duty = value;
            }
        }

        /// <summary>
        /// 职称
        /// </summary>		
        public virtual string Title
        {
            get { return _Title; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Title", value, value.ToString());

                _IsChanged |= (_Title != value); _Title = value;
            }
        }

        /// <summary>
        /// 用户密码
        /// </summary>		
        public virtual string UserPassword
        {
            get { return _UserPassword; }
            set
            {
                if (value != null)
                    if (value.Length > 200)
                        throw new ArgumentOutOfRangeException("Invalid value for UserPassword", value, value.ToString());

                _IsChanged |= (_UserPassword != value); _UserPassword = value;
            }
        }

        /// <summary>
        /// 改变密码时间
        /// </summary>		
        public virtual DateTime? ChangePasswordDate
        {
            get { return _ChangePasswordDate; }
            set { _IsChanged |= (_ChangePasswordDate != value); _ChangePasswordDate = value; }
        }

        /// <summary>
        /// QQ号码
        /// </summary>		
        public virtual string QICQ
        {
            get { return _QICQ; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for QICQ", value, value.ToString());

                _IsChanged |= (_QICQ != value); _QICQ = value;
            }
        }

        /// <summary>
        /// 电子邮件
        /// </summary>		
        public virtual string Email
        {
            get { return _Email; }
            set
            {
                if (value != null)
                    if (value.Length > 200)
                        throw new ArgumentOutOfRangeException("Invalid value for Email", value, value.ToString());

                _IsChanged |= (_Email != value); _Email = value;
            }
        }

        /// <summary>
        /// 系统语言选择
        /// </summary>		
        public virtual string Lang
        {
            get { return _Lang; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Lang", value, value.ToString());

                _IsChanged |= (_Lang != value); _Lang = value;
            }
        }

        /// <summary>
        /// 系统样式选择
        /// </summary>		
        public virtual string Theme
        {
            get { return _Theme; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Theme", value, value.ToString());

                _IsChanged |= (_Theme != value); _Theme = value;
            }
        }

        /// <summary>
        /// 允许登录开始时间
        /// </summary>		
        public virtual DateTime? AllowStartTime
        {
            get { return _AllowStartTime; }
            set { _IsChanged |= (_AllowStartTime != value); _AllowStartTime = value; }
        }

        /// <summary>
        /// 允许登录结束时间
        /// </summary>		
        public virtual DateTime? AllowEndTime
        {
            get { return _AllowEndTime; }
            set { _IsChanged |= (_AllowEndTime != value); _AllowEndTime = value; }
        }

        /// <summary>
        /// 暂停登录开始时间
        /// </summary>		
        public virtual DateTime? LockStartDate
        {
            get { return _LockStartDate; }
            set { _IsChanged |= (_LockStartDate != value); _LockStartDate = value; }
        }

        /// <summary>
        /// 暂停登录结束时间
        /// </summary>		
        public virtual DateTime? LockEndDate
        {
            get { return _LockEndDate; }
            set { _IsChanged |= (_LockEndDate != value); _LockEndDate = value; }
        }

        /// <summary>
        /// 第一次登录时间
        /// </summary>		
        public virtual DateTime? FirstVisit
        {
            get { return _FirstVisit; }
            set { _IsChanged |= (_FirstVisit != value); _FirstVisit = value; }
        }

        /// <summary>
        /// 上一次登录时间
        /// </summary>		
        public virtual DateTime? PreviousVisit
        {
            get { return _PreviousVisit; }
            set { _IsChanged |= (_PreviousVisit != value); _PreviousVisit = value; }
        }

        /// <summary>
        /// 最后登录时间
        /// </summary>		
        public virtual DateTime? LastVisit
        {
            get { return _LastVisit; }
            set { _IsChanged |= (_LastVisit != value); _LastVisit = value; }
        }

        /// <summary>
        /// 登录次数
        /// </summary>		
        public virtual int LogOnCount
        {
            get { return _LogOnCount; }
            set { _IsChanged |= (_LogOnCount != value); _LogOnCount = value; }
        }

        /// <summary>
        /// 是否职员
        /// </summary>		
        public virtual int IsStaff
        {
            get { return _IsStaff; }
            set { _IsChanged |= (_IsStaff != value); _IsStaff = value; }
        }

        /// <summary>
        /// 审核状态
        /// </summary>		
        public virtual string AuditStatus
        {
            get { return _AuditStatus; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for AuditStatus", value, value.ToString());

                _IsChanged |= (_AuditStatus != value); _AuditStatus = value;
            }
        }

        /// <summary>
        /// 是否显示
        /// </summary>		
        public virtual int IsVisible
        {
            get { return _IsVisible; }
            set { _IsChanged |= (_IsVisible != value); _IsVisible = value; }
        }

        /// <summary>
        /// 在线状态
        /// </summary>		
        public virtual int UserOnLine
        {
            get { return _UserOnLine; }
            set { _IsChanged |= (_UserOnLine != value); _UserOnLine = value; }
        }

        /// <summary>
        /// IP地址
        /// </summary>		
        public virtual string IPAddress
        {
            get { return _IPAddress; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for IPAddress", value, value.ToString());

                _IsChanged |= (_IPAddress != value); _IPAddress = value;
            }
        }

        /// <summary>
        /// MAC地址
        /// </summary>		
        public virtual string MACAddress
        {
            get { return _MACAddress; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for MACAddress", value, value.ToString());

                _IsChanged |= (_MACAddress != value); _MACAddress = value;
            }
        }

        /// <summary>
        /// 家庭住址
        /// </summary>		
        public virtual string HomeAddress
        {
            get { return _HomeAddress; }
            set
            {
                if (value != null)
                    if (value.Length > 200)
                        throw new ArgumentOutOfRangeException("Invalid value for HomeAddress", value, value.ToString());

                _IsChanged |= (_HomeAddress != value); _HomeAddress = value;
            }
        }

        /// <summary>
        /// 单点登录标识
        /// </summary>		
        public virtual string OpenId
        {
            get { return _OpenId; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for OpenId", value, value.ToString());

                _IsChanged |= (_OpenId != value); _OpenId = value;
            }
        }

        /// <summary>
        /// 密码提示问题代码
        /// </summary>		
        public virtual string Question
        {
            get { return _Question; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for Question", value, value.ToString());

                _IsChanged |= (_Question != value); _Question = value;
            }
        }

        /// <summary>
        /// 密码提示答案
        /// </summary>		
        public virtual string AnswerQuestion
        {
            get { return _AnswerQuestion; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for AnswerQuestion", value, value.ToString());

                _IsChanged |= (_AnswerQuestion != value); _AnswerQuestion = value;
            }
        }

        /// <summary>
        /// 用户默认地址
        /// </summary>		
        public virtual string UserAddress
        {
            get { return _UserAddress; }
            set
            {
                if (value != null)
                    if (value.Length > 200)
                        throw new ArgumentOutOfRangeException("Invalid value for UserAddress", value, value.ToString());

                _IsChanged |= (_UserAddress != value); _UserAddress = value;
            }
        }

        /// <summary>
        /// 删除标志
        /// </summary>		
        public virtual int DeleteMark
        {
            get { return _DeleteMark; }
            set { _IsChanged |= (_DeleteMark != value); _DeleteMark = value; }
        }

        /// <summary>
        /// 有效
        /// </summary>		
        public virtual int Enabled
        {
            get { return _Enabled; }
            set { _IsChanged |= (_Enabled != value); _Enabled = value; }
        }

        /// <summary>
        /// 排序码
        /// </summary>		
        public virtual int? SortCode
        {
            get { return _SortCode; }
            set { _IsChanged |= (_SortCode != value); _SortCode = value; }
        }

        /// <summary>
        /// 描述
        /// </summary>		
        public virtual string Description
        {
            get { return _Description; }
            set
            {
                if (value != null)
                    if (value.Length > 800)
                        throw new ArgumentOutOfRangeException("Invalid value for Description", value, value.ToString());

                _IsChanged |= (_Description != value); _Description = value;
            }
        }

        /// <summary>
        /// 创建日期
        /// </summary>		
        public virtual DateTime? CreateOn
        {
            get { return _CreateOn; }
            set { _IsChanged |= (_CreateOn != value); _CreateOn = value; }
        }

        /// <summary>
        /// 创建用户主键
        /// </summary>		
        public virtual string CreateUserId
        {
            get { return _CreateUserId; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for CreateUserId", value, value.ToString());

                _IsChanged |= (_CreateUserId != value); _CreateUserId = value;
            }
        }

        /// <summary>
        /// 创建用户
        /// </summary>		
        public virtual string CreateBy
        {
            get { return _CreateBy; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for CreateBy", value, value.ToString());

                _IsChanged |= (_CreateBy != value); _CreateBy = value;
            }
        }

        /// <summary>
        /// 修改日期
        /// </summary>		
        public virtual DateTime? ModifiedOn
        {
            get { return _ModifiedOn; }
            set { _IsChanged |= (_ModifiedOn != value); _ModifiedOn = value; }
        }

        /// <summary>
        /// 修改用户主键
        /// </summary>		
        public virtual string ModifyUserId
        {
            get { return _ModifyUserId; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for ModifyUserId", value, value.ToString());

                _IsChanged |= (_ModifyUserId != value); _ModifyUserId = value;
            }
        }

        /// <summary>
        /// 修改用户
        /// </summary>		
        public virtual string ModifiedBy
        {
            get { return _ModifiedBy; }
            set
            {
                if (value != null)
                    if (value.Length > 50)
                        throw new ArgumentOutOfRangeException("Invalid value for ModifiedBy", value, value.ToString());

                _IsChanged |= (_ModifiedBy != value); _ModifiedBy = value;
            }
        }

        /// <summary>
        /// 对象的值是否被改变
        /// </summary>
        public virtual bool IsChanged
        {
            get { return _IsChanged; }
        }

        /// <summary>
        /// 对象是否已经被删除
        /// </summary>
        public virtual bool IsDeleted
        {
            get { return _IsDeleted; }
        }

        #endregion

        #region 公有函数

        /// <summary>
        /// 标记对象已删除
        /// </summary>
        public virtual void MarkAsDeleted()
        {
            _IsDeleted = true;
            _IsChanged = true;
        }


        #endregion

        #region 重写Equals和HashCode
        /// <summary>
        /// 用唯一值实现Equals
        /// </summary>
        public override bool Equals(object obj)
        {
            if (this == obj) return true;
            if ((obj == null) || (obj.GetType() != GetType())) return false;
            PiUserEntity castObj = (PiUserEntity)obj;
            return (castObj != null) &&
                (_Id == castObj.Id);
        }

        /// <summary>
        /// 用唯一值实现GetHashCode
        /// </summary>
        public override int GetHashCode()
        {
            int hash = 57;
            hash = 27 * hash * _Id.GetHashCode();
            return hash;
        }
        #endregion

         /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataRow">数据行</param>
        public PiUserEntity(DataRow dataRow)
        {
            this.GetFrom(dataRow);
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="dataTable">数据表</param>
        public PiUserEntity(DataTable dataTable)
        {
            this.GetFrom(dataTable);
        }

        /// <summary>
        /// 从数据表读取
        /// </summary>
        /// <param name="dataTable">数据表</param>
        public PiUserEntity GetFrom(DataTable dataTable)
        {
            if ((dataTable == null) || (dataTable.Rows.Count == 0))
            {
                return null;
            }
            foreach (DataRow dataRow in dataTable.Rows)
            {
                this.GetFrom(dataRow);
                break;
            }
            return this;
        }

        /// <summary>
        /// 从数据行读取
        /// </summary>
        /// <param name="dataRow">数据行</param>
        public PiUserEntity GetFrom(DataRow dataRow)
        {
            this.Id = int.Parse(dataRow[PiUserTable.FieldId].ToString());
            this.Code = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldCode]);
            this.UserName = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldUserName]);
            this.RealName = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldRealName]);
            this.RoleId = BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldRoleId]);
            this.UserFrom = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldUserFrom]);
            this.WorkCategory = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldWorkCategory]);
            this.CompanyId = BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldCompanyId]);
            this.CompanyName = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldCompanyName]);
            this.DepartmentId = BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldDepartmentId]);
            this.DepartmentName = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldDepartmentName]);
            this.WorkgroupId = BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldWorkgroupId]);
            this.WorkgroupName = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldWorkgroupName]);
            this.Gender = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldGender]);
            this.Mobile = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldMobile]);
            this.Telephone = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldTelephone]);
            this.Birthday = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldBirthday]);
            this.Duty = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldDuty]);
            this.Title = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldTitle]);
            this.UserPassword = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldUserPassword]);
            this.ChangePasswordDate = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldChangePasswordDate]);
            this.QICQ = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldQICQ]);
            this.Email = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldEmail]);
            this.Lang = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldLang]);
            this.Theme = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldTheme]);
            this.AllowStartTime = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldAllowStartTime]);
            this.AllowEndTime = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldAllowEndTime]);
            this.LockStartDate = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldLockStartDate]);
            this.LockEndDate = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldLockEndDate]);
            this.FirstVisit = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldFirstVisit]);
            this.PreviousVisit = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldPreviousVisit]);
            this.LastVisit = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldLastVisit]);
            this.LogOnCount = int.Parse(dataRow[PiUserTable.FieldLogOnCount].ToString());
            this.IsStaff = int.Parse(BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldIsStaff]).ToString());
            this.AuditStatus = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldAuditStatus]);
            this.IsVisible = int.Parse(BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldIsVisible]).ToString());
            this.UserOnLine = int.Parse(BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldUserOnLine]).ToString());
            this.IPAddress = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldIPAddress]);
            this.MACAddress = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldMACAddress]);
            this.HomeAddress = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldHomeAddress]);
            this.OpenId = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldOpenId]);
            this.Question = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldQuestion]);
            this.AnswerQuestion = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldAnswerQuestion]);
            this.UserAddress = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldUserAddress]);
            this.DeleteMark = int.Parse(BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldDeleteMark]).ToString());
            this.Enabled = int.Parse(BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldEnabled]).ToString());
            this.SortCode = BusinessLogic.ConvertToInt(dataRow[PiUserTable.FieldSortCode]);
            this.Description = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldDescription]);
            this.CreateOn = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldCreateOn]);
            this.CreateUserId = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldCreateUserId]);
            this.CreateBy = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldCreateBy]);
            this.ModifiedOn = BusinessLogic.ConvertToDateTime(dataRow[PiUserTable.FieldModifiedOn]);
            this.ModifyUserId = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldModifyUserId]);
            this.ModifiedBy = BusinessLogic.ConvertToString(dataRow[PiUserTable.FieldModifiedBy]);
            return this;
        }

    }

    #region Custom ICollection interface for PiUser


        public interface IPiUserEntityCollection : ICollection
        {
            PiUserEntity this[int index] { get; set; }
            void Add(PiUserEntity pPiUser);
            void Clear();
        }

        [Serializable]
        public class PiUserCollection : IPiUserEntityCollection
        {
            private IList<PiUserEntity> _arrayInternal;

            public PiUserCollection()
            {
                _arrayInternal = new List<PiUserEntity>();
            }

            public PiUserCollection(IList<PiUserEntity> pSource)
            {
                _arrayInternal = pSource;
                if (_arrayInternal == null)
                {
                    _arrayInternal = new List<PiUserEntity>();
                }
            }

            public PiUserEntity this[int index]
            {
                get
                {
                    return _arrayInternal[index];
                }
                set
                {
                    _arrayInternal[index] = value;
                }
            }

            public int Count { get { return _arrayInternal.Count; } }
            public bool IsSynchronized { get { return false; } }
            public object SyncRoot { get { return _arrayInternal; } }
            public void CopyTo(Array array, int index) { _arrayInternal.CopyTo((PiUserEntity[])array, index); }
            public IEnumerator GetEnumerator() { return _arrayInternal.GetEnumerator(); }
            public void Add(PiUserEntity pPiUser) { _arrayInternal.Add(pPiUser); }
            public void Clear() { _arrayInternal.Clear(); }
            public IList<PiUserEntity> GetList() { return _arrayInternal; }
        }
        #endregion
}
